package com.polly.esphwevent.common.disruptor;

import com.lmax.disruptor.WorkHandler;
import com.polly.esphwevent.event.AssessmentPublishEvent;
import com.polly.esphwevent.event.AssessmentRespondenceEvent;
import lombok.extern.slf4j.Slf4j;

/**
 * @title: HomeworkEventHandler
 * @description: TODO(用一句话描述该文件做什么)
 * @date: 2019/2/12 14:48
 * @author ldz112@163.com
 * @version V1.0
 */
@Slf4j
public class HomeworkEventHandler  implements WorkHandler<HomeworkEvent> {


    @Override
    public void onEvent(HomeworkEvent homeworkEvent) throws Exception {

        log.info("接收到事件消息：{}",homeworkEvent.getHomeworkId());

        switch(homeworkEvent.getEventType()){
            case PUBLISH_EVENT:
                new AssessmentPublishEvent(homeworkEvent.getHomeworkId(),homeworkEvent.getUserId()).execute();
                break;
            case RESPONDENCE_EVENT:
                new AssessmentRespondenceEvent(homeworkEvent.getHomeworkId(),homeworkEvent.getUserId()).execute();
                break;
            default:

        }



    }
}
